import Store from '../../store/';
import {
    DIC
} from '@/const/dic';
const allPermission = Store.state.user.permission;
const isAdmin = Store.state.user.userInfo.superAdmin;
export const bannerInfoTableOption = {
    border: false,
    index: false,
    selection: true,
    calcHeight: 350,
    columnBtn: false,
    searchClearable: false,
    selectClearBtn: false,
    searchResetBtn: false,
    height: "auto",
    menu: true,
    menuAlign: "center",
    searchBtn: true,
    labelWidth: 120,
    refreshBtn: true,
    tip: false,
    addBtn: true,
    dialogWidth: '800px',
    dialogHeight: 'auto',
    menuWidth: 180,
    editBtn: isAdmin || !!allPermission['/admin/banner-info/update'],
    viewBtn: false,
    delBtn: isAdmin || !!allPermission['/admin/banner-info/remove-by-id'],
    column: [
        
        // {
        //     "label": "banner类型",
        //     "prop": "bannerType",
        //     "search": true,
        //     "type": "select",
        //     "fixed": false,
        //     "width": "140",
        //     "row": false,
        //     "minWidth": "140",
        //     "readonly": false,
        //     props: {
        //         label: 'label',
        //         value: 'value'
        //     },
        //     dicUrl: '/admin/banner-info/list',
        //     dicMethod: 'post',
        //     "span": 12,
        //     "display": true,
        //     "hide": false,
        //     "rules": [
        //         {
        //             "required": false,
        //             "message": "请选择banner类型",
        //             "trigger": "blur"
        //         }
        //     ]
        // },
        {
            "label": "banner类型",
            "prop": "bannerType",
            "search": true,
            "type": "tag",
            "fixed": false,
            "width": "140",
            "row": false,
            "dicData": DIC.bannerType,
            "minWidth": "140",
            "readonly": false,
            change:(v)=>{
                console.log(bannerInfoTableOption)
                v.value == 1?bannerInfoTableOption.column[2].tip="只能上传jpg/png文件，且不超过2M,尺寸（708*329）":bannerInfoTableOption.column[2].tip="只能上传jpg/png文件，且不超过2M,尺寸（527*278）"
                v.value == 1?bannerInfoTableOption.column[1].display = false:bannerInfoTableOption.column[1].display = true
            },
            props: {
                label: 'label',
                value: 'value'
            },
            // dicUrl: '/admin/banner-info/list',
            dicMethod: 'post',
            "span": 12,
            "display": true,
            "hide": false,
            "rules": [
                {
                    "required": true,
                    "message": "请选择banner类型",
                    "trigger": "blur"
                }
            ]
        },
        {
            "label": "商品分类",
            "prop": "linkDataId",
            "search": true,
            "type": "select",
            "fixed": false,
            "width": "140",
            "row": false,
            "minWidth": "140",
            "readonly": false,
            props: {
                label: 'categoryName',
                value: 'id'
            },
            formatter(value,row){
                return row == 0?"首页顶部":row
            },
            dicUrl: '/admin/goods_category/list',
            dicMethod: 'post',
            "span": 12,
            "display": true,
            "hide": false,
            "rules": [
                {
                    "required": false,
                    "message": "请选择商品分类",
                    "trigger": "blur"
                }
            ]
        },
        
        {
            "label": "banner图片",
            "prop": "bannerImg",
            "search": false,
            "type": "upload",
            "fixed": false,
            "width": "120",
            "row": true,
            "minWidth": "120",
            "readonly": false,
            "span": 24,
            "display": true,
            "hide": false,
            "listType": "picture-img",
            "showFileList": false,
            "imgHeight": 60,
            "imgWidth": "auto",
            "action": "_/admin/upload/image",
            "tip":"只能上传jpg/png文件，且不超过2M,尺寸（708*329）",
            "rules": [{
                "required": true,
                "message": "请上传banner图片",
                "trigger": "blur"
            }]
        },
        // {
        //     "label": "banner链接类型",
        //     "prop": "bannerTypeLink",
        //     "search": false,
        //     "type": "tag",
        //     "fixed": false,
        //     "width": "140",
        //     "row": false,
        //     "dicData": [{
        //         label: '秒杀',
        //         value: 1,
        //     }, {
        //         label: '爆款',
        //         value: 2,
        //     },{
        //         label: '猜你喜欢',
        //         value: 3,
        //     }],
        //     "minWidth": "140",
        //     "readonly": false,
        //     change:(v)=>{
        //         console.log(bannerInfoTableOption)
        //     },
        //     props: {
        //         label: 'label',
        //         value: 'value'
        //     },
        //     "span": 12,
        //     "display": true,
        //     "hide": false
        // },
        {
            "label": "banner链接地址",
            "prop": "bannerLinkUrl",
            "search": false,
            "type": "text",
            "fixed": false,
            "width": "auto",
            "row": false,
            "minWidth": "180",
            "readonly": false,
            // formatter(value,row){
            //     return '/shopPages/pages/shop/detail?id='+row;
            // },
            "span": 12,
            "display": true,
            "hide": false
        },
        {
            "label": "开始时间",
            "prop": "startTime",
            "search": false,
            "type": "datetime",
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss",
            "fixed": false,
            "width": "170",
            "row": false,
            "readonly": false,
            "span": 12,
            "display": true,
            "hide": false,
            "rules": [{
                "required": true,
                "message": "请选择开始时间",
                "trigger": "blur"
            }]
        },
        {
            "label": "结束时间",
            "prop": "endTime",
            "search": false,
            "type": "datetime",
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss",
            "fixed": false,
            "width": "170",
            "row": false,
            "readonly": false,
            "span": 12,
            "display": true,
            "hide": false,
            "rules": [{
                "required": true,
                "message": "请选择结束时间",
                "trigger": "blur"
            }]
        },
        {
            "label": "排序",
            "prop": "sort",
            "search": false,
            "type": "number",
            "fixed": false,
            "width": "100",
            "row": false,
            "readonly": false,
            "span": 12,
            "display": true,
            "hide": false
        },
        {
            "label": "创建人",
            "prop": "creator",
            "search": false,
            "type": "text",
            "fixed": false,
            "width": "120",
            "row": false,
            "minWidth": "120",
            "readonly": false,
            "span": 12,
            "display": false,
            "hide": false
        },
        {
            "label": "创建时间",
            "prop": "createTime",
            "search": false,
            "type": "datetime",
            "fixed": false,
            "width": "170",
            "row": false,
            "readonly": false,
            "span": 12,
            "display": false,
            "hide": false
        },
        
       
        {
            "label": "修改时间",
            "prop": "modifyTime",
            "search": false,
            "type": "datetime",
            "fixed": false,
            "width": "170",
            "row": false,
            "readonly": false,
            "span": 12,
            "display": false,
            "hide": false
        },
        {
            "label": "修改人",
            "prop": "modifier",
            "search": false,
            "type": "text",
            "fixed": false,
            "width": "120",
            "row": false,
            "minWidth": "120",
            "readonly": false,
            "span": 12,
            "display": false,
            "hide": false
        }
    ]
};
